<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        window.onload = function () {
            var qx = document.getElementById("qx");
            var qbx = document.getElementById("qbx");
            var fx = document.getElementById("fx");
            qx.onclick = function () {
                var cks = document.getElementsByName("ck");
                for (var i = 0; i < cks.length; i++) {
                    cks[i].checked = true;
                }
            };
            qbx.onclick = function () {
                var cks = document.getElementsByName("ck");
                for (var i = 0; i < cks.length; i++) {
                    cks[i].checked = false;
                }
            };
            fx.onclick = function () {
                var cks = document.getElementsByName("ck");
                for (var i = 0; i < cks.length; i++) {
                     if(cks[i].checked){
                         cks[i].checked = false;
                     }else{
                         cks[i].checked = true;
                     }
                }
            };
        };
    </script>
</head>
<body>
<input type="button" value="全选" id="qx">
<input type="button" value="全不选" id="qbx">
<input type="button" value="反选" id="fx"><br>
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
<input type="checkbox" name="ck">
</body>
</html>